
import ToastComponent from './toast.vue'
const Toast = {};
// 注册Toast
Toast.install = function (Vue) {
  const ToastConstructor = Vue.extend(ToastComponent);
  const instance = new ToastConstructor();
  instance.$mount(document.createElement('div'));
  document.body.appendChild(instance.$el);
  //接受三个参数，1.提示文字内容，2.提示的类型（成功success,警告warning,错误error,信息info(默认)）,3.显示后多久消失
  Vue.prototype.$toast = (msg,type='info', duration = 1500) => {
    instance.message = msg;
    instance.type = type;
    instance.visible = true;
    setTimeout(() => {
      instance.visible = false;
    }, duration);
  }
};
export default Toast
